package com.itheima.reggie.controller;

import com.itheima.reggie.common.R;
import com.itheima.reggie.pojo.SetmealDto;
import com.itheima.reggie.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/setmeal")
public class SetmealController {
    @Autowired
    private SetmealService setmealService;

    @PostMapping
    public R addSetmeal(@RequestBody SetmealDto setmealDto) {
        return setmealService.addSetmeal(setmealDto);
    }

    @GetMapping("/page")
    public R page(Integer page,Integer pageSize,String name) {
        return setmealService.page(page,pageSize,name);
    }

    @DeleteMapping
    public R deleteByIds(Long[] ids) {
        return setmealService.deleteByIds(ids);
    }
    @PostMapping("/status/{id}")//批量起售和停售
    public R upDataSt(@PathVariable Integer id,Long[] ids) {
        return setmealService.upDataSt(id,ids);
    }
    @GetMapping("/{id}")//修改回显
    public R findById(@PathVariable Long id) {
        return setmealService.findById(id);
    }
    @PutMapping
    public R upDataSetmeal(@RequestBody SetmealDto setmealDto) {
        return setmealService.upDataSetmeal(setmealDto);
    }
    @GetMapping("/list")
    public R list(Long categoryId,Integer statues){
        R r = setmealService.list(categoryId,statues);
        return r;
    }
}
